home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 11612 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: mudskipper.cac.psu.edu!user
  2. From: fcusack@tdx.org (frank.)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: static and dynamic classes in C++ ?
  5. Date: Thu, 14 Mar 1996 21:03:38 -0400
  6. Organization: Soylent Green is People!!
  7. Message-ID: <fcusack-1403962103390001@mudskipper.cac.psu.edu>
  8. References: <3148472F.41C6@informatik.uni-siegen.de>
  9. NNTP-Posting-Host: mudskipper.cac.psu.edu
  10.  
  11. In article <3148472F.41C6@informatik.uni-siegen.de>, Runu Knips
  12. <plrunu@informatik.uni-siegen.de> wrote:
  13.  
  14. > Hi people!
  15. > 1. Is it possible to declare a class in a way that only
  16. > dynamic instances of it may be declared ?
  17.  
  18. hmm... judging by question 2, I assume you mean "on the free store". There
  19. is a way to ensure that a class can only be constructed via the new
  20. operator. I am not sure what it is (so why did I post! :\ ) but my guess
  21. is that it is to make the constructor(s) private and overload the new
  22. operator.
  23.  
  24. > 2. Is it also possible to declare a class in a way that
  25. > only static (i.e. stack or data segment) instances may
  26. > be declared ?
  27.  
  28. Overload the new operator and have it fail to construct a new object always.
  29.  
  30. ~Frank
  31.  -- I am Pentium of Borg.  Division is futile.  You will be approximated. --
  32.  -- PGP ID: 1C0F6685 | NCB#56 | Visit me --> http://www.tdx.org/~fcusack/ --
  33.